﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Trackr.DataAccess
{
	public static class Resolver
	{
		public static T Get<T>() where T : ITrackrDataStore
		{
			Type defaultImplementation = GetDefaultDataStoreType();
			T obj = (T)Activator.CreateInstance(defaultImplementation);
			return obj;
			//var fakeStore = new FakeTrackrDataStore();
			//return (ITrackrDataStore)fakeStore;
		}

		private static Type GetDefaultDataStoreType()
		{
			return typeof(FakeTrackrDataStore);
			//var mng = System.Configuration.ConfigurationManager.GetSection("Trackr") as DataAccessConfig;
			//DataAccessConfigElement element = mng.Instances[mng.Default];
			//string assName = "Trackr.SqlLiteProvider";
			//string typeName ="Trackr.SqlLiteProvider.TrackrDataTable";
			//var assembly = System.Reflection.Assembly.Load(assName);
			//var type = assembly.DefinedTypes.Where(t => t.FullName == typeName).FirstOrDefault();
			//return type.ReflectedType;
		}
	}
}
